import os, django
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "api_automation_test.settings")
django.setup()
from requests import request
from backend.api.getResult import getResult, Lyzd_RunMsg
from backend.serializers import Lyzd_RunMsgSerializer
def runScript():
	content = {"progect_id":1,
		"environment_id":1,
		"interface_action":['1', '2'] ,
		"execute": '0'}
	msg = getResult.get(request, content)
	"""Query the latest running results"""
	maxid_msg_data = Lyzd_RunMsg.objects.latest()
	maxid_msg_data.id
	msg_data = Lyzd_RunMsg.objects.filter(id=maxid_msg_data.id)
	serialize = Lyzd_RunMsgSerializer(msg_data, many=True)
	runResult = eval(serialize.data[0]['msg'])
	sum=str(runResult['共执行接口数量'])
	success=str(runResult['执行成功数量'])
	fial=str(runResult['执行失败数量'])
	returnStdout = "共执行接口数量"+sum+"个,执行成功的数量"+success+"个,执行失败的数量"+fial+"个"
	return returnStdout
